
/**
 * Created by forcht on 2018/5/17.
 */
public class Solution {
    public int reverse(int x) {
        long sum=0;
        while (x!=0){
            sum=sum*10+x%10;
            x/=10;
        }
        if(sum>Integer.MAX_VALUE||sum<Integer.MIN_VALUE)return 0;
        return (int) sum;
    }

    public static void main(String[] args) {
        Solution solution=new Solution();
        System.out.println(solution.reverse(1000));
    }
}
